package team.sun.sss.dao.sturoutine;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import team.sun.sss.pojo.student.Student1;
import team.sun.sss.pojo.sturoutine.SrLeave;

import java.util.List;


@Mapper
@Repository
public interface SrLeaveDao {
    @Select("select * from sr_leave where stu_id=#{stuId}")
    List<SrLeave> getSrLeaveList(int stuId);//查询学生个人信息

    @Select("select * from sr_leave where leave_num=#{leave_num}")
    List<SrLeave> getLeaveList(int leave_num);//查询学生请假申请信息

    @Select("select student.*,sr_leave.* from student,sr_leave where student.stu_id=sr_leave.stu_id")
    List<SrLeave> getStaffLeaveList();

    @Select("select student.*,sr_leave.* from student,sr_leave where student.stu_id=sr_leave.stu_id")
    List<SrLeave> getInsLeaveList();

    @Select("select student.*,sr_leave.* from student,sr_leave where leave_applytime=#{leaveApplytime} and student.stu_id=sr_leave.stu_id")
    List<SrLeave> getLeaveSelect(String leaveApplytime);//用申请时间查询学生请假相关信息

    @Insert("insert into sr_leave(stu_id,leave_reason,leave_destination,leave_applytime,leave_time,leave_time2,leave_applystate)values(#{stuId},#{leaveReason},#{leaveDestination},#{leaveApplytime},#{leaveTime},#{leaveTime2},\"1\")")
    int addSrLeave(int stuId, String leaveReason, String leaveDestination, String leaveApplytime, String leaveTime, String leaveTime2);//新增学生请假信息

    @Update("update sr_leave set leave_reason=#{LeaveReason},leave_destination=#{LeaveDestination},leave_applytime=#{LeaveApplytime},leave_time=#{LeaveTime},leave_time2=#{LeaveTime2} where leave_num=#{num}")
    int updateLeave(String LeaveReason, String LeaveDestination, String LeaveApplytime, String LeaveTime, String LeaveTime2, int num);//学生修改学生请假申请信息

    @Update("update sr_leave set leave_applystate=#{LeaveApplystate} where leave_num=#{num} ")
    int staffUpdateLeave(String LeaveApplystate, int num);//管理员审核学生申请信息

    @Update("update sr_leave set leave_applystate=#{LeaveApplystate} where leave_num=#{num}")
    int InsUpdateLeave(String LeaveApplystate, int num);//教师审核学生申请信息

    @Delete("delete from sr_leave where leave_num=#{leave_num}")
    int deleteSrLeave(int num);//删除请假申请信息

}
